package com.bkgy.controller.allprocessRcl2150.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bkgy.controller.allprocessRcl2150.dto.AllProcessTbYieldRcl2150Requst;
import com.bkgy.controller.allprocessRcl2150.entity.TbYieldRcl2150;
import com.bkgy.controller.allprocessRcl2150.mapper.ITbYieldRcl2150Mapper;
import com.bkgy.controller.allprocessRcl2150.service.AllProcessRcl2150Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AllProcessRcl2150ServiceImpl  implements AllProcessRcl2150Service {

    @Autowired
    private ITbYieldRcl2150Mapper mapper;

    @Override
    /**
     * Rcl2150 明细表_分页;
     * @param request AllProcessTbYieldRcl2150Requst
     * @return ResultData
     */
    public ResultData rcl2150detais(AllProcessTbYieldRcl2150Requst request) {
        try {
            //前端日期转Rcl格式
            request.setDbegin(setTimes_Rcl(request.getDbegin()));
            request.setDend(setTimes_Rcl(request.getDend()));

            Integer count=0;
            Page<?> page = new Page<>(request.getPageIndex(), request.getPageSize());
            List<TbYieldRcl2150> list = mapper.rcl2150detais(page,request);
            count = (int)page.getTotal();
            return ResultData.ResultDataSuccess(list, count);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultData.ResultDataFaultSelf("获取失败" + e.getMessage(), null);
        }
    }

    /**
     * 前台传入日期转Rcl日期格式
     * @param front_Times  2025-09-15 00:00:00.000000
     * @return 时间格式：2025/6/01 00:00:01
     */
    public String setTimes_Rcl(String front_Times) {
        String Times_Rcl = "2025/09/15 09:13:11";//时间格式：2025/6/01 00:00:01
        try {
            String[] array_Time = front_Times.split("-");//时间格式：2025-06-01 00:00:01
            String times = array_Time[2].substring(0, 11);
            Times_Rcl = array_Time[0] +"/"+ array_Time[1] +"/"+ times;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return Times_Rcl;
    }


}